#include "utils.h"
#include "aclnn_fast_gelu.h"
extern "C"
{
    int run(void *env_ptr, void *x, void *y)
    {
        uint64_t workspaceSize;
        aclOpExecutor *executor;
        // 调用aclnnAdd第一段接口
        auto ret = aclnnFastGeluGetWorkspaceSize(
            CAST_TO_ACL_TENSOR(x),
            CAST_TO_ACL_TENSOR(y),
            &workspaceSize, &executor);
        CHECK_SUCCESS_RETURN(ret, "aclnnFastGeluGetWorkspaceSize failed.");
        // 根据第一段接口计算出的workspaceSize申请device内存
        ALLOC_WORKSPACE(workspaceSize);
        // 调用aclnnAddCustom第二段接口
        ret = aclnnFastGelu(workspaceAddr, workspaceSize, executor, GET_STREAM(env_ptr));
        CHECK_SUCCESS_RETURN(ret, "aclnnFastGelu failed.")

        return ACL_SUCCESS;
    }
}